﻿Imports System
Imports System.Windows
Imports System.Windows.Forms
Imports System.Windows.Forms.Control

Namespace XPControl
    Public NotInheritable Class CkeckBox
        Private Shared Ctrl As System.Windows.Forms.Control

        Public Shared Function CheckCheckBox(ByVal chk As System.Windows.Forms.CheckBox) As Integer
            If chk.Checked = True Then
                Return 1
            Else
                Return 0
            End If
        End Function

        Public Overloads Shared Sub CheckStatusCheckBox(ByVal Chk As System.Windows.Forms.CheckBox)
            If CheckCheckBox(Chk) = 1 Then
                Chk.Checked = True
            Else
                Chk.Checked = False
            End If
        End Sub

        Public Overloads Shared Sub CheckStatusCheckBox(ByVal I As Integer, ByVal Chk As System.Windows.Forms.CheckBox)
            If I = 1 Then
                Chk.Checked = True
            Else
                Chk.Checked = False
            End If
        End Sub

        Public Shared Sub CheckEnableControl(ByVal chk As System.Windows.Forms.CheckBox, ByVal Dtp As System.Windows.Forms.Control)
            If chk.Checked = True Then
                Dtp.Enabled = True
            Else
                Dtp.Enabled = False
            End If
        End Sub

        Public Shared Sub CheckVisibleControl(ByVal chk As System.Windows.Forms.CheckBox, ByVal Ctrl As System.Windows.Forms.Control)
            If chk.Checked = True Then
                Ctrl.Visible = True
            Else
                Ctrl.Visible = False
            End If
        End Sub

        Public Shared Sub EnableCheckBoxInGB(ByVal gb As System.Windows.Forms.GroupBox)
            For Each Ctrl As System.Windows.Forms.Control In gb.Controls
                If TypeOf Ctrl Is CheckBox Then Ctrl.Enabled = True
            Next
        End Sub

        Public Shared Sub DisableCheckBoxInGB(ByVal gb As System.Windows.Forms.GroupBox)
            For Each Ctrl As System.Windows.Forms.Control In gb.Controls
                If TypeOf Ctrl Is CheckBox Then Ctrl.Enabled = False
            Next
        End Sub

        Public Shared Sub EnableCheckBoxInTab(ByVal Tab As System.Windows.Forms.TabPage)
            For Each Ctrl As System.Windows.Forms.Control In Tab.Controls
                If TypeOf Ctrl Is CheckBox Then Ctrl.Enabled = True
            Next
        End Sub

        Public Shared Sub DisableCheckBoxInTab(ByVal Tab As System.Windows.Forms.TabPage)
            For Each Ctrl As System.Windows.Forms.Control In Tab.Controls
                If TypeOf Ctrl Is CheckBox Then Ctrl.Enabled = False
            Next
        End Sub

    End Class
End Namespace
